<?php include "../public/header.php"?>
<?php include '../public/header_public.php' ?>
<style>
    .layui-table-fixed-l .layui-table-header{width: 42px;}
    .layui-table-tool{padding-left:0;}
</style>
<body>
<div class="layui-fluid layui-fluid_list">
    <div class="layui-row layui-col-space15">
        <div class="layui-col-md12">
            <div class="layui-card">
                <div class="layui-card-body">
                    <div id="datalist" lay-filter="datalist"></div>
                </div>
            </div>
        </div>
    </div>
</div>

<script type="text/html" id="toolbarDemo">
    <button class = "layui-btn layui-btn-sm btn-dark" onclick="go_cert_use()"><i class="layui-icon">&#xe654;</i>投标用证</button>
</script>
<script type="text/html" id="operation">
    <div class="tab-list-authbut">
        <a href="javascript:;" class="bar_opt" lay-event="del">取消</a>
    </div>
</script>

<script>
    // 获取父页面的idsArr
    var idArr = parent.get_idArr();

    var idStr = idArr.join(',');
    function go_cert_use(){
        parent.openPageEdit('../cert_use/flow_add.php?close=1&type=1&ids='+idStr);
    }


    layui.use(['form','table','laytp'],function() {
        var form = layui.form;
        var table = layui.table;
        var laytp = layui.laytp;

        table.render({
            elem: "#datalist",id: "datalist"
            ,url: facade.url(ask_cert_matching_alloc),where: {idArr: idArr}, page: false, height: 'full-140'
            ,soulSort: TabInit.soulSort,method: TabInit.method, toolbar: '#toolbarDemo', overflow: TabInit.overflow
            ,defaultToolbar: false,filter: TabInit.filter
            ,request: TabInit.request,response: TabInit.response
            ,text: TabInit.text
            ,parseData: function(res){
                return {
                    "code": res.code,
                    "msg": res.message,
                    "data": res.data
                };
            }
            ,cols: [[
                {type: 'numbers', title: '序号',fixed:'left'}
                ,{field: 'person_name', title: '持证人'}
                ,{field: 'person_nature', title: '人员性质'}
                ,{field: 'name', title: '证书名称'}
                ,{field: 'major', title: '证书专业'}
                ,{field: 'number', title: '证书编号'}
                ,{field: 'chanid_name', title: '归属单位'}
                ,{field: 'cert_status', title: '当前状态'}
                ,{title: '操作',templet: '#operation', fixed: 'right',width:120}
            ]]
            ,done: function(res, curr, count){
                $(".layui-dropdown").parent('.layui-table-cell').css('overflow', 'visible');
                layui.config({
                    base: '../../lib/dropdown/'
                }).extend({
                    dropdown: 'dropdown'
                }).use(['dropdown'],function() {
                    var dropdown = layui.dropdown;
                    dropdown.render();
                });
            }
        });

        table.on('tool(datalist)', function(obj){
            var data = obj.data;
            if(obj.event === 'del'){
                layer.confirm('是否取消该行数据？', function(index){
                    idArr.splice($.inArray(data.id, idArr), 1);
                    parent.set_idArr(idArr);
                    obj.del();
                    layer.close(index);
                });
            }
        });

        // 详情
        table.on('toolbar(datalist)',function (obj) {
            var checkStatus = table.checkStatus(obj.config.id);
            var data = checkStatus.data;
            if(obj.event === 'add'){
                if(idArr.length === 0){
                    layer.msg('请选择证书');return false;
                }
                parent.open_cert_use_bid();
            }
        });

    });
</script>
</body>
</html>
